export default {
	data() {
		return {
			share: {
				title: '绿色果蔬田地种，大家齐动手，新鲜蔬果带家走😄~',
				path: '',
				// imageUrl: 'https://www.tdtye.com/files/vegetable_mall_file/plot/20539330662342481/bbe66caba0b420cc06862a1be924e8d9.jpeg'
			}
		}
	},
	onLoad(e) {
		this.imgApi = this.$reqConfig.URLIMAGE
		//先存父id，防止先调接口未登录直接跳页面了
		if (e.parentId != undefined && e.parentId != "") {
			uni.setStorageSync("parentId", e.parentId)
		} else {
			console.log("e.parentId: ", e.parentId);
			let token = uni.getStorageSync("token")
			let route = this.$mp.page.route;
			if (!token && route != "pages/mine/loginPage") {
				//不需要先登录的添加在这里
				if (route == "pages/growVegetables/growVegetables") {
					return;
				}
				if (route == "pages/shop/shop") {
					return;
				}
				if (route == "pageA/mine/agreement") {
					return;
				}
				if (route == "pageA/growVegetables/vegetablesList") {
					return;
				}
				uni.navigateTo({
					url: '../../pages/mine/loginPage'
				})
			}
			
			// 所有没有单独在页面监听分享事件的，页面分享后都会跳转到首页，如果需要页面跳转到指定页面，那么就在那个页面复制下面这段内容
			//this.shar.path那段就是分享出去后跳转进来的链接，最后一个Itemid就是那个页面所要携带的参数
			// onShareAppMessage(res) {
			// 	let usId = uni.getStorageSync("usId")
			// 	let route = this.$mp.page.route;
			// 	this.share.path = route + `?&parentId=${uni.getStorageSync("usId")}&itemId=` + this.itemId
			// 	this.share.imageUrl=""
			// 	return this.share
			// },
		}
		//分享事件黑名单
		const urlList = [
			'pageA/growVegetables/woyaozhongOrder',
			'merchant/',
		]
		//获取路由信息
		const pages = getCurrentPages()	
		//获取当前路由
		let nowPage = pages[pages.length - 1]
		urlList.forEach(item => {
			if (nowPage.route.indexOf(item) != -1) {
				uni.hideShareMenu()
			}
		})
	},

	//分享好友
	onShareAppMessage(res) {
		let usId = uni.getStorageSync("usId")
		let route = this.$mp.page.route;
		this.share.path = 'pages/growVegetables/growVegetables' + `?&parentId=${uni.getStorageSync("usId")}`
		return this.share
	},
	// #ifdef MP-WEIXIN
	//朋友圈
	onShareTimeline() {
		return this.share
	},
	// #endif

}
